// Vue实例
import Vue from 'vue'
import App from '@/App'
import router from '@/router'
import store from '@/store'
// ui框架
import Element from 'element-ui'
import '@/icons'
import 'element-ui/lib/theme-chalk/index.css'
import '@/assets/scss/aui.scss'
import '@/assets/scss/style.scss'
// 字体
import '@/assets/program-font/program-font.scss'
// 可视化
import VCharts from 'v-charts'
import echarts from 'echarts'
import VcChart from 'vc-chart'
// 视频播放器
import VideoPlayer from 'vue-video-player' // 信息屏中使用
// 视频样式
import 'video.js/dist/video-js.css'
import 'vue-video-player/src/custom-theme.css'
// 国际化
import i18n from '@/i18n'
// 列表无缝滚动
import scroll from 'vue-seamless-scroll'
// 接口请求
import {
  http
} from '@/utils/request'
// 是否接口权限
import {
  hasPermission
} from '@/utils'
// 加解密
import CryptoTool from '@/utils/cryptoTool'
// 加解密方法
import aes from './assets/crypto-aes'
// 代码高亮指令
import Highlight from '@/utils/highlight'
// 可视化富文本编辑器
import tinymce from 'tinymce'
import VueTinymce from '@packy-tang/vue-tinymce'
// 深拷贝
import cloneDeep from 'lodash/cloneDeep'
// 二维码
import QRcode from '@/components/QRcode'
Vue._watchers = Vue.prototype._watchers = [] // 首页map方法报错
// 高德地图
// import VueAMap from 'vue-amap'
// 阻止vue启动生产消息
Vue.config.productionTip = false

// 挂载全局
Vue.prototype.$echarts = echarts // 挂载到Vue实例上面
Vue.prototype.cryptoAes = aes
Vue.prototype.$tinymce = tinymce // 将全局tinymce对象指向给Vue作用域下
Vue.prototype.$http = http
Vue.prototype.$hasPermission = hasPermission

// 保存整站vuex本地储存初始状态
window.SITE_CONFIG['storeState'] = cloneDeep(store.state)
// 获取保存在本地缓存中的权限列表
let permissions = localStorage.getItem('permissions')
if (permissions) {
  permissions = CryptoTool.decrypt(permissions)
  permissions = permissions.split(',')
} else {
  permissions = []
}
window.SITE_CONFIG['storeState'].permissions = permissions

// 主观组件
// Vue.use(VueAMap)
Vue.use(QRcode)
Vue.use(VCharts)
Vue.use(VideoPlayer)
Vue.use(VcChart)
Vue.use(Highlight)
Vue.use(scroll)
Vue.use(VueTinymce) // 安装vue的tinymce组件
Vue.use(Element, {
  size: 'default',
  i18n: (key, value) => {
    return i18n.t(key, value)
  }
})

// 实例挂载
new Vue({
  i18n,
  router,
  store,
  render: h => h(App),
  // 安装事件总线
  beforeCreate () {
    Vue.prototype.$bus = this
  }
}).$mount('#app')
